using System;
using UnityEngine;
using UnityEngine.UI;

namespace PKGames.Localization
{
	[Serializable]
	internal class LocalizedField
	{
		[SerializeField]
		private Text _textField;

		[SerializeField]
		private string _localizationKey;

		public Text TextField
		{
			get
			{
				return _textField;
			}
			set
			{
				_textField = value;
			}
		}

		public string LocalizationKey
		{
			get
			{
				return _localizationKey;
			}
			set
			{
				_localizationKey = value;
			}
		}

		public void UpdateLocalizedText(LocationProvider locationProvider)
		{
			if (_textField != null)
			{
				_textField.text = locationProvider.GetLocalizedString(_localizationKey);
			}
			else
			{
				UnityEngine.Debug.Log("[LocalizedField] Object is null from key: " + _localizationKey);
			}
		}
	}
}
